package com.xxx.modules.controller;;
import com.xxx.modules.service.BackService;
import com.xxx.modules.entity.Back;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import com.xxx.modules.utils.Result;
import com.xxx.modules.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * back
 *  留言管理
 *
 * @author 北易航
 * @since 1.0.0 2022-12-19
 */
@RestController
@RequestMapping("/common/back")
@Api(tags="back")
public class BackController {
    @Autowired
    private BackService backService;

    /**
    *  查询所有back
    * @param pageNum
    * @param pageSize
    * @param back
    * @return
    */

    @GetMapping("/getBackInfo")
    @ApiOperation("获取所有留言")
    public Result getBackInfo(Back back, @RequestParam(value="pageNum",defaultValue = "1") Integer pageNum,
                                      @RequestParam(value="pageSize",defaultValue = "10") Integer pageSize){
        PageInfo<Back> data = backService.selectBackInfo(back,pageNum,pageSize);
        return ResultUtil.success(1,"成功",data);
    }

    /**
    * 保存back
    * @param back
    * @return
    */
    @PostMapping("/saveBackInfo")
    @ApiOperation("保存留言")
    public Result saveBackInfo(@RequestBody Back back){
        backService.saveBackInfo(back);
        return ResultUtil.success(1,"成功",null);
    }


    /**
     * 更新back
     * @param back
     * @return
     */

    @PutMapping("/updateBackInfo")
    @ApiOperation("更新")
    public Result updateBackInfo(@RequestBody Back back){
        backService.updateBackInfo(back);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id删除back
     * @param id
     * @return
     */
    @DeleteMapping("/delBackInfo")
    public Result delBackInfo(Integer id){
        backService.delBackInfo(id);
        return ResultUtil.success(1,"成功",null);
    }

    /**
     * 根据id集合删除back
     * @param idList
     * @return
     */
    @DeleteMapping("/delBatchBackInfo")
    public Result delBatchBackInfo(String idList){
        backService.delBatchBackInfo(idList);
        return ResultUtil.success(1,"成功",null);
    }

}